Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Language Guide / Part 2 - AppleScript Language Reference
Chapter 5 - Objects and References / Reference Forms


Every Element

The Every Element reference form specifies every object of a particular class in a container.

SYNTAX
every className 
pluralClassName
where

className is a singular class name (such as word or paragraph).

pluralClassName is the plural form defined by AppleScript or an application (such as words or paragraphs). The plural form of an object class name has the same effect as the word every before an object class name. Plural forms are listed in application dictionaries.

VALUE
The value of an Every Element reference is a list of the objects in the container. If the container does not contain any objects of the specified class, the list is an empty list. For example, the value of the expression

every paragraph of {1, 2, 3}
is the empty list:

{}
EXAMPLES
The following example assigns a string to the variable myString, and then uses the Every Element reference form to specify every word contained in
the string.

set myString to "That's all, folks"every word of myString
The value of the reference every word of myString is a list with
three items:

{"That's", "all", "folks"}
The following reference specifies the same list:

words of myString
The following references specify a list of all the words in the first paragraph of a document.

tell front document of application "Scriptable Text Editor"   every word of paragraph 1
   words of paragraph 1
end tell
NOTES
If you specify an Every Element reference as the container for a property or object, the result is a list containing the specified property or object for each object of the container. The number of items in the list is the same as the number of objects in the container. For example, the value of the reference

length of every word
is a list such as

{ 2, 3, 6 }
The first item in the list is the length of the first word, the second item is the length of the second word, and so on.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996